home *** CD-ROM | disk | FTP | other *** search
- # Jedi Knight Cog Script
- #
- # FORCE_PROJECT.COG
- #
- # FORCEPOWER Script - Projection
- # Bin 36
- #
- # [YB]
- #
- # (C) 1997 LucasArts Entertainment Co. All Rights Reserved
-
-
- symbols
-
- thing player local
-
- flex cost=50.0 local
- int rank local
- flex mana local
- model weaponMesh=fistg.3do local
-
- sound projSound=FProject.WAV local
- template projection_tpl=+Projection local
-
- int projection=-1 local
- flex randval=0.0 local
- int strafed=0 local
- int turned=0 local
-
- int myMode=-1 local
- int attachFlags local
-
- int inbubble=0 local
-
- message startup
- message activated
- message newplayer
- message killed
- message selected
- message timer
- message enterbubble
- message exitbubble
- message pulse
-
- end
-
- # ========================================================================================
-
- code
-
- startup:
- player = GetLocalPlayerThing();
- inbubble = 0;
- call stop_power;
-
- Return;
-
- # ........................................................................................
-
- activated:
- if(inbubble) Return;
-
- // Cannot cast underwater...
- if(GetSectorFlags(GetThingSector(player)) & 2) Return;
-
- // Must be attached to a world surface or thing face
- attachFlags = GetAttachFlags(player);
- if(!((attachFlags & 1) || (attachFlags & 2))) Return;
-
- // Must not be crouching
- if(IsThingCrouching(player)) Return;
-
- if((!IsInvActivated(player, 36)) && (GetThingHealth(player) > 0))
- {
- mana = GetInv(player, 14);
- if(mana >= cost || GetInv(player, 14) >= GetInv(player, 69))
- {
- if(GetInv(player, 64) != 1) ChangeInv(player, 14, -cost);
-
- // Send a "force disturbance"...
- if(!IsMulti())
- SendMessageExRadius(GetThingPos(player), cost, 0x4, splash, 36, 0, 0, 0);
-
- SetInvActivated(player, 36, 1);
-
- PlayMode(player, 24);
- PlaySoundThing(projSound, player, 1.0, -1, -1, 0x80);
-
- rank = GetInv(player, 36);
-
- // Create the projection
- projection = CreateThing(projection_tpl, player);
-
- // Assign it the same model
- SetThingModel(projection, GetThingModel(player));
-
- // Add a hand/weapon mesh to the model
- jkSetWeaponMesh(projection, weaponMesh);
-
- // Make it collidable in single player (AI stuff)
- if(!IsMulti()) SetCollideType(projection, 1);
-
- SetTimerEx(8 * rank, 0, 0, 0);
- SetPulse(1);
- }
- }
-
- Return;
-
- # ........................................................................................
-
- timer:
- call stop_power;
- Return;
-
- # ........................................................................................
-
- pulse:
- if(projection != -1)
- {
- // stop current anim if any
- if(myMode != -1)
- {
- StopKey(projection, myMode, 0.0);
- myMode = -1;
- }
-
- if(jkGetBubbleDistance(projection) <= 1.0)
- {
- call stop_power;
- Return;
- }
-
- randval = rand();
-
- if(randval < 0.5)
- {
- // do another action quicker after a fire
- SetPulse(0.33);
-
- // Fire
- myMode = PlayMode(projection, 8);
- }
- else
- if(randval < 0.99)
- {
- SetPulse(0.5 + rand());
-
- // if we had a strafe put the character in place
- // we don't want him to move...
- if(strafed)
- {
- // Counterstrafe
- if(strafed == 1)
- {
- myMode = PlayMode(projection, 6);
- }
- else
- {
- myMode = PlayMode(projection, 5);
- }
- strafed = 0;
- }
- else
- if(turned)
- {
- // Counterturn
- if(turned == 1)
- {
- myMode = PlayMode(projection, 32);
- }
- else
- {
- myMode = PlayMode(projection, 31);
- }
- turned = 0;
- }
- // we did not strafe or turn previously, chose an action
- else
- {
- if(rand() < 0.5)
- {
- // turn
- if(rand() < 0.5)
- {
- myMode = PlayMode(projection, 31);
- turned = 1;
- }
- else
- {
- myMode = PlayMode(projection, 32);
- turned = 2;
- }
- }
- else
- {
- // strafe
- if(rand() < 0.5)
- {
- myMode = PlayMode(projection, 5);
- strafed = 1;
- }
- else
- {
- myMode = PlayMode(projection, 6);
- strafed = 2;
- }
- }
- }
- }
- }
- Return;
-
- # ........................................................................................
-
- selected:
- jkPrintUNIString(player, 36);
- Return;
-
- # ........................................................................................
-
- killed:
- if(GetSenderRef() != player) Return;
-
- newplayer:
- call stop_power;
-
- Return;
-
- # ........................................................................................
-
- enterbubble:
- inbubble = 1;
- call stop_power;
- Return;
-
- # ........................................................................................
-
- exitbubble:
- inbubble = 0;
- Return;
-
- # ........................................................................................
-
- stop_power:
- SetPulse(0);
- SetInvActivated(player, 36, 0);
- if(projection != -1)
- {
- DestroyThing(projection);
- projection = -1;
- }
-
- Return;
-
- end
-
-
-
-